package themis.flink.riskengine;

import com.alibaba.fastjson.JSONObject;
import org.apache.flink.api.common.functions.MapFunction;

public class RuleBasedModeling implements MapFunction<JSONObject, JSONObject> {
    public JSONObject map(JSONObject value) throws Exception {
        boolean isAnomaly = (value.getJSONObject("features").getDouble("count(pay_account.history,1h)") > 5.0D
                && value.getJSONObject("features").getDouble("sum(amount#rcv_account.history,1h)") > 5000.0D
                && value.getJSONObject("features").getDouble("count_distinct(rcv_account#pay_account.history,1h)") <= 2.0D);
        value.put("isAnomaly", isAnomaly);
        return value;
    }
}
